package com.sqlcheck.dto.request;

import com.sqlcheck.common.enums.DatabaseType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.Map;

/**
 * 大模型优化请求
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "大模型优化请求")
public class LLMOptimizeRequest {

    @Schema(description = "任务ID", example = "123")
    private Long taskId;

    @NotBlank(message = "SQL内容不能为空")
    @Size(max = 65535, message = "SQL内容长度不能超过65535字符")
    @Schema(description = "SQL内容", required = true)
    private String sql;

    @NotNull(message = "源数据库类型不能为空")
    @Schema(description = "源数据库类型", required = true)
    private DatabaseType sourceDbType;

    @NotNull(message = "目标数据库类型不能为空")
    @Schema(description = "目标数据库类型", required = true)
    private DatabaseType targetDbType;

    @Schema(description = "兼容性规则列表")
    private java.util.List<String> rules;

    @Schema(description = "大模型配置")
    private LLMConfig llmConfig;

    @Schema(description = "附加上下文信息")
    private Map<String, Object> additionalContext;

    /**
     * 大模型配置
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "大模型配置")
    public static class LLMConfig {

        @Schema(description = "提供商", example = "openai")
        private String provider;

        @Schema(description = "模型名称", example = "gpt-4-turbo-preview")
        private String modelName;

        @Schema(description = "最大token数", example = "4000")
        private Integer maxTokens;

        @Schema(description = "温度参数", example = "0.1")
        private Double temperature;

        @Schema(description = "超时时间(秒)", example = "30")
        private Integer timeout;

        @Schema(description = "自定义请求头")
        private Map<String, String> headers;

        @Schema(description = "自定义参数")
        private Map<String, Object> parameters;
    }
}